<?php
	function alertWeek($text,$color,$icon)
	{
		$colors = array
		(
			'red'=>'#ff0000',
			'yellow'=>'#FFFB00',
			'green'=>'#00ff00',
		);
		$icons = array
		(
			'family'=>'images/family_super_small.png',
			'business'=>'images/briefcase_super_small.png',
			'pleasure'=>'images/coffee_super_small.png',
		);
		return 
		'<VBox width="100%" height="100%" horizontalAlign="center" verticalAlign="middle" backgroundColor="'.$colors[$color].'" backgroundAlpha="0.3" cornerRadius="2" click="dispatchEvent(viewstack1, \'eventpreview\')">
			<Text text="'.$text.'"/>
			<Image source="'.$icons[$icon].'" width="20" height="20" />
		</VBox>';
	}
	function checkWeekAlert($day,$hour)
	{
		$events = array
		(
			1=>array
			(
				9=>array('Important Meeting','red','business'),
				12=>array('See Lover','green','pleasure')
			),
			2=>array
			(
				17=>array('Wash Car','green','family'),
				20=>array('Visit Mother in Law','red','family')
			),
			3=>array
			(
				14=>array('UMFISNI','red','business'),
				18=>array('Study Analysis','green','business')
			),
			4=>array
			(
				14=>array('Go to Restaurant','green','pleasure'),
				17=>array('Go to Dentist','red','family')
			),
			5=>array
			(
				13=>array('Call Boss','yellow','business'),
				15=>array('Watch football','green','pleasure'),
				17=>array('Pick up kids','yellow','family'),
				20=>array('Cook Dinner','red','family')
			),
			6=>array
			(
				14=>array('Pick up Sellary','yellow','business'),
				17=>array('Play football','green','pleasure'),
				9=>array('Walk the Dog','yellow','family'),
				0=>array('Watch History Channel','red','pleasure')
			),
			7=>array
			(
				12=>array('Go to the Mountain','green','family')
			)
		);
		#$events = array();
		if(isset($events[$day][$hour]))
		{
			return alertWeek
			(
				$events[$day][$hour][0],
				$events[$day][$hour][1],
				$events[$day][$hour][2]
			);
		}
		return '';
	}
?>
<Canvas label="Week view" width="100%" height="100%" horizontalAlign="center">
	<HBox width="95%" height="100%" horizontalAlign="center">
		<Grid borderStyle="none" width="95%" verticalGap="5" backgroundColor="#eeeeee" backgroundAlpha="0.5">
			<GridRow backgroundColor="#f0f0f0" width="100%">
				<GridItem width="12%"><Text text=""/></GridItem>
				<GridItem width="11%"><Text text="Mon"/></GridItem>
				<GridItem width="11%"><Text text="Tue"/></GridItem>
				<GridItem width="11%"><Text text="Wed"/></GridItem>
				<GridItem width="11%"><Text text="Thu"/></GridItem>
				<GridItem width="11%"><Text text="Fri"/></GridItem>
				<GridItem width="11%"><Text text="Sat"/></GridItem>
				<GridItem width="11%"><Text text="Sun"/></GridItem>
				<GridItem width="11%"><Text text=""/></GridItem>
			</GridRow>
			<?php
				for($i=0;$i<=23;$i++)
				{
					?><GridRow <?php echo ($i%2)?'':'backgroundColor="#f0f0f0"'; ?> width="100%" backgroundAlpha="0.5">
						<GridItem width="12%" height="50"><Text text="<?php echo $i;?>:00"/></GridItem>
						<GridItem width="12%" height="50"><?php echo checkWeekAlert(1,$i) ?></GridItem>
						<GridItem width="12%" height="50"><?php echo checkWeekAlert(2,$i) ?></GridItem>
						<GridItem width="12%" height="50"><?php echo checkWeekAlert(3,$i) ?></GridItem>
						<GridItem width="12%" height="50"><?php echo checkWeekAlert(4,$i) ?></GridItem>
						<GridItem width="12%" height="50"><?php echo checkWeekAlert(5,$i) ?></GridItem>
						<GridItem width="12%" height="50"><?php echo checkWeekAlert(6,$i) ?></GridItem>
						<GridItem width="12%" height="50"><?php echo checkWeekAlert(7,$i) ?></GridItem>
						<GridItem width="4%" height="50"><Text text=""/></GridItem>
					</GridRow><?php
				}
			?>
			<GridRow backgroundColor="#f0f0f0" width="100%">
				<GridItem width="12%"><Text text=""/></GridItem>
				<GridItem width="11%"><Text text="Mon"/></GridItem>
				<GridItem width="11%"><Text text="Tue"/></GridItem>
				<GridItem width="11%"><Text text="Wed"/></GridItem>
				<GridItem width="11%"><Text text="Thu"/></GridItem>
				<GridItem width="11%"><Text text="Fri"/></GridItem>
				<GridItem width="11%"><Text text="Sat"/></GridItem>
				<GridItem width="11%"><Text text="Sun"/></GridItem>
				<GridItem width="11%"><Text text=""/></GridItem>
			</GridRow>
		</Grid>
	</HBox>
</Canvas>